package org.liulinlin.sejw.db;

import java.sql.*;

public class Customer { //extends DataAccessServiceImpl {
	private String id;
	private String name;
	private String type;
	private CustomerContact customerContact;
	private String manager;
	private String property;
	private String addr;
	private String zip;
	private String bank;
	private String taxNo;
	private String bankID;
	private String tel;
	private String fax;
	private String web;
	
	public Customer() {
		
	}
	
	public Customer(String id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("不能获得数据库连接");
			return;
		}
		
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery("select * from Customer where Customer_ID = '" + id + "'");
		
			rs.next();
			this.id = id;
			name = rs.getString("Customer_Name");
			type = rs.getString("Customer_Type");
			customerContact = new CustomerContact(rs.getString("CC_ID"));
			manager = rs.getString("Customer_Manager");
			property = rs.getString("Customer_Property");
			addr = rs.getString("Customer_Addr");
			zip = rs.getString("Customer_Zip");
			bank = rs.getString("Customer_Bank");
			taxNo = rs.getString("Customer_TaxNo");
			bankID = rs.getString("Customer_BankID");
			tel = rs.getString("Customer_Tel");
			fax = rs.getString("Customer_Fax");
			web = rs.getString("Customer_Web");
		
			rs.close();
			stmt.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		connMgr.release();
	}
	
	public void setId(String id) {
		this.id = id;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setType(String type) {
		this.type = type;
	}
	public void setCustomerContact(CustomerContact customerContact) {
		this.customerContact = customerContact;
	}
	public void setManager(String manager) {
		this.manager = manager;
	}
	public void setProperty(String property) {
		this.property = property;
	}
	public void setAddr(String addr) {
		this.addr = addr;
	}
	public void setZip(String zip) {
		this.zip = zip;
	}
	public void setBank(String bank) {
		this.bank = bank;
	}
	public void setTaxNo(String taxNo) {
		this.taxNo = taxNo;
	}
	public void setBankID(String bankID) {
		this.bankID = bankID;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public void setFax(String fax) {
		this.fax = fax;
	}
	public void setWeb(String web) {
		this.web = web;
	}
	
	public String getId() {
		return id;
	}
	public String getName() {
		return name;
	}
	public String getType() {
		return type;
	}
	public CustomerContact getCustomerContact() {
		return customerContact;
	}
	public String getManager() {
		return manager;
	}
	public String getProperty() {
		return property;
	}
	public String getAddr() {
		return addr;
	}
	public String getZip() {
		return zip;
	}
	public String getBank() {
		return bank;
	}
	public String getTaxNo() {
		return taxNo;
	}
	public String getBankID() {
		return bankID;
	}
	public String getTel() {
		return tel;
	}
	public String getFax() {
		return fax;
	}
	public String getWeb() {
		return web;
	}
}
